#include "GameScene.h"
#include "GameLayer.h"
#include "GameSoundMgr.h"
#include "UIMain.h"

GameScene::GameScene()
{
	m_pUIMain = NULL;
}

GameScene::~GameScene()
{

}

GameScene* GameScene::create()
{
	GameScene* p = new GameScene();
	if (p && p->init())
	{
		p->autorelease();
		return p;
	}

	CC_SAFE_DELETE(p);
	return NULL;
}

bool GameScene::init()
{
	CCScene::init();

	CCLayer* bgLayer = CCLayer::create();
	CCSprite* pSprite = CCSprite::create("image/background01.jpg");
	pSprite->setAnchorPoint(ccp(0.5, 0.5));
	// position the sprite on the center of the screen
	pSprite->setRotation(90);
	pSprite->setPosition(ccp(400, 240));
	bgLayer->addChild(pSprite, 0);
	addChild(bgLayer);

	m_pLayer = GameLayer::create();
	addChild(m_pLayer);

	m_pUIMain = UIMain::create();
	addChild(m_pUIMain);
	return true;
}

void GameScene::onEnter()
{
	CCScene::onEnter();
	GameSoundMgr::getInstance()->playBackgroundMusic("raw/background.ogg", true);
}

